﻿using System;
using System.Collections.Generic;

class Solution
{
    static List<int> getFactors(int num)
    {
        List<int> factors = new List<int>();
        for (int i = 1; i <= num / 2; i++)
        {
            if (num % i == 0)
            {
                factors.Add(i);
            }
        }
        return factors;
    }

    static void findPerfectNumbers(int limit)
    {
        List<int> perfectNumbers = new List<int>();
        for (int i = 1; i <= limit; i++)
        {
            int sum = 0;
            foreach (int factor in getFactors(i))
            {
                sum += factor;
            }
            if (sum == i)
            {
                perfectNumbers.Add(i);
            }
        }
        Console.WriteLine(string.Join(", ", perfectNumbers));
    }

    public static void Main(string[] args)
    {
        int limit = 1000;
        findPerfectNumbers(limit);
    }
}
